package cn.tyz.kotlin.glide

import android.content.Context
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory
import android.widget.ImageView

/**
 * @author : tianyingzhong
 * @ClassName: CircularBitmapImageViewTarget
 * @Description:
 * @time 2017/8/23 20:05
 */
internal class CircularBitmapImageViewTarget(var context: Context, var imageView: ImageView):
        com.bumptech.glide.request.target.BitmapImageViewTarget(imageView){
    /**
     * 绘制圆角的Bitmap
     */
    override fun setResource(bitmap: android.graphics.Bitmap?) {
        var bitmapDrawable= RoundedBitmapDrawableFactory.create(context.resources,bitmap)
        bitmapDrawable.isCircular=true
        imageView.setImageDrawable(bitmapDrawable)
    }
}